package com.xxxx.server.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xxxx.server.mapper.DepartmentMapper;
import com.xxxx.server.pojo.Department;
import com.xxxx.server.pojo.RespBean;
import com.xxxx.server.service.IDepartmentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;



/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zhoubin
 */
@Service
public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements IDepartmentService {

    @Resource
    private DepartmentMapper departmentMapper;


    @Override
    public List<Department> findAllDepartment() {
        return departmentMapper.findAllDepartment(-1);
    }

    @Override
    public RespBean insertDepartment(Department department) {
        if (departmentMapper.insertDepartment(department)==1){
            return RespBean.success("添加成功！");
        }
        return RespBean.error("添加失败");
    }

    @Override
    public RespBean deleteDepartment(Integer id) {
       if (departmentMapper.deleteDepartment(id)==1){
            return RespBean.success("删除成功！");
       }
        return RespBean.error("删除失败");
    }
}
